<?php
/**
 * Object Relational Persistence Mapping Class for table: template_equipment_item
 *
 * @package	com.athena
 * @author	LHV
 */
class TemplateEquipmentItem extends ORDataObject {

	/**#@+
	 * Fields of table: template_equipment_item mapped to class members
	 */
	var $template_equipment_item_id		= '';
	var $template_equipment_id		= '';
	var $surgery_equipment_id		= '';
	var $quantity		= '';
	var $vi_quantity_title		= '';
	var $en_quantity_title		= '';
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'template_equipment_item';

	/**
	 * Primary Key
	 */
	var $_key = 'template_equipment_item_id';

	/**
	 * Internal Name
	 */
	var $_internalName = 'TemplateEquipmentItem';

	/**
	 * Handle instantiation
	 */
	function TemplateEquipmentItem() {
		parent::ORDataObject();
	}


	function deleteAllRecord($templateId){
		$sql = "DELETE FROM $this->_table WHERE template_equipment_id = $templateId";
		$this->_execute($sql);
	}

	function addRecord( $templateId, $equipmentId,  $quantity, $qualityTitle){
		$qualityTitleLang = L10nHelper::changeField(L10nHelper::getLocale(),"quantity_title");
		$data = array(
					'template_equipment_id'	=> $templateId,
					'surgery_equipment_id'	=> $equipmentId,
					'quantity'				=> $quantity,
					$qualityTitleLang		=> $qualityTitle
				);

		$this->populateArray($data);
		$this->persist();
	}
}
?>
